
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;

public class Csv {

    public static void main(String[] argv) throws IOException {

        final File outPutFile = new File("./example/repay_plan_20161102.csv");
        final File checkFile = new File("./example/check_repay_plan_20161102");

        final CSVPrinter outPutPrinter = CSVFormat.RFC4180.withHeader(
                "parter","loan_id","term_no","start_date","end_date","prin_amt","int_amt")
                .print(outPutFile, Charset.forName("UTF-8"));

        outPutPrinter. printRecord(new ArrayList<String>());
        outPutPrinter.printRecord("gome","xxxxxxx","2","20160202","20160302","50000","333");
        outPutPrinter.close();

        final CSVPrinter checkFilePrinter = CSVFormat.RFC4180.withHeader(
                "file_name","row_count")
                .print(checkFile, Charset.forName("UTF-8"));
        checkFilePrinter.printRecord("repay_plan",2);
        checkFilePrinter.close();
    }

}